//屏蔽js错误
function ResumeError() {
return true;
}
window.onerror = ResumeError;


function splitstr(str)
{
	tx=str.split("fileurl=");
	return tx[1];
}

function getfile(id,codeid,price)
{
return;
  $.ajax({ 
        type: "POST", 
        url: "getfile.php", 
        dataType: "text", 
        data: {"id":id,"codeid":codeid}, 
        beforeSend: function(){ 
          // $("p").html("正在登录...");
        }, 
 success: function(data){ 

      //$("p").remove();
	  //alert(data)
	  if(data.indexOf("fileurl")!=-1){	
	   
	   location.href= splitstr(data);
	  }
	    else if (data.indexOf("password is null")!=-1){
		alert("账号或者密码为空");
			location.href='login.php'; 
		}
		
		else if (data.indexOf("password is wrong")!=-1){
		alert("账号或者密码不正确");
			location.href='login.php'; 
		}
		
		
	  
	  else if (data.indexOf("no pay")!=-1){
		 
		 if(confirm("您还没有购买此资源，购买需花费"+ price+" 元。是否购买？")) 
		 {
		  //location.href="order.php";
		       $.ajax({ 
        type: "POST", 
        url: "saveorder.php", 
        dataType: "text", 
        data: {"codeid":codeid}, 
   
 success: function(data1){ 
   	  if(data1.indexOf("order is ok")!=-1){	
	   
	    alert("购买成功,请再次点击下载按钮下载文件");
		return;
	  }
	  else if(data1.indexOf("codeid is null")!=-1){
		  
		 alert("资源编号为空");
		return;  
		  }
		  
		    else if(data1.indexOf("product is null")!=-1){
		  
		 alert("资源数据出错");
		 return;  
		 
		  }
		  	    else if(data1.indexOf("money less")!=-1){
		  
	 if(confirm("您的账号余额不足购买该资源，是否充值？")) 
		 {
			location.href='pay.php'; 
			 }
		 
		 
		return; 
		 
		  }	  
	  
	  
 }})
		   //end 
		 }
		  
		  }
	  
	  
	  else
	  {
		  alert("无法下载");
		  return;
		}
		
		
		
 }
  })
}


function login(userid,password,gurl){
	if(userid==""){
		$("#ts").empty();	
		  $("#ts").html("账号为空，请填写！");
		  return;
		}
			if(password==""){
		$("#ts").empty();	
		  $("#ts").html("密码为空，请填写！");
		  return;
		}
	$.ajax({ 
        type: "POST", 
        url: "xml/public.php", 
        dataType: "text", 
        data: {"btn":true,"userid":userid,"password":password,"gurl":gurl}, 
        beforeSend: function(){ 
      
        }, 
 success: function(data){
 
   
 
  if(data.indexOf("userid or password is wrong")!=-1){
	  $("#ts").empty();	
    $("#ts").html("账号或者密码错误，请重新输入！");
	  return;
 }
	  
	   
  if(data.indexOf("login is ok")!=-1){
	    $("#ts").empty();
	if($("#gurl").val()!=""){
		location.href=$("#gurl").val();
		}
	  
		return;
	  }
 }
 
		 })
}
//发表评论
function pinfl(content,fenshu,apkid,total){
	 $.ajax({ 
        type: "POST", 
        url: "xml/public.php", 
        dataType: "text", 
        data: {"pl":true,"content":content,"fenshu":fenshu,"apkid":apkid}, 
        beforeSend: function(){ 
		 $(".red").show();
      // $(".red").html("正在发表评论...");
        }, 
 success: function(data){
//alert( );
	   if(data.indexOf("has pl")!=-1){
			 $(".red").html("请不要连续发表评论！");
			$(".red").css("color","#ff0000");
            $(".red").fadeTo(600,1);
		setTimeout("$('.red').fadeTo(600,0)",1000);
		return false;
		   }
		      else{
				total++;  
			$(".pinjbnt a").html("评论（"+total+"）");
			$(".pingjia h4 font").html("共"+total+"条评论");
		   $(".red").html("发表评论成功！");
			$(".red").css("color","#006633");
            $(".red").fadeTo(600,1);
		setTimeout("$('.red').fadeTo(600,0)",1000);
		
		 if($('.wangyou').length>0){
		$('.wangyou:first').before(data);
		//alert(data);
		 }
		 if($('.wangyou').length==0){
		$('#ckgd').empty();//清空提示语
		 $('#ckgd').before(data);
		 }
		   }
		   
		 return true;
	 }
	 })
	
	}

function pingf(codeid,xing,phit){
	var flag=0;
      for(i=0;i<$(":radio:checked").length;i++)
        if($(":radio:checked").get(0).checked=true){
            flag=1;
			 $.ajax({ 
        type: "POST", 
        url: "xml/public.php", 
        dataType: "text", 
        data: {"tp":true,"codeid":codeid,"xing":xing,"pf":$(":radio:checked").val(),"phit":phit}, 
        beforeSend: function(){ 
          // $("p").html("正在登录...");
        }, 
 success: function(data){ 
//alert(data);
 if(data.indexOf("has tp")!=-1){
	 
	$("#cr").html("您已经投过票啦！");
			$("#cr").css("color","#ff0000");
            $("#cr").fadeTo(600,1);
		setTimeout("$('#cr').fadeTo(600,0)",2000);
	 
	 }
	 else{
		// alert(data);
		$("#cr").html("您已成功投票");
			$("#cr").css("color","#006633");
            $("#cr").fadeTo(600,1);
			setTimeout("$('#cr').fadeTo(600,0)",2000);
        }
		return false;
	 }
})
			
 }
        if(!flag){
			$("#cr").html("请选择投票选项");
			$("#cr").css("color","#ff0000");
            $("#cr").fadeTo(600,1);
		setTimeout("$('#cr').fadeTo(600,0)",2000);
            return false
        }
}

//查看更多评论
 function xmlsx(start,size,id,page){
       	$.ajax({
                 url: "xml/m_pinglun.php",
				 type:"POST",
                  datatype:"text",
                 data: {"pl":"true","start":start,"size":size,"id":id,"page":page}, 
                 beforeSend: function(){ 
                }, 
              success: function (data) {
				  $('#gdpl').hide();
		         $('#ckgd').append("<div id='sss'><bdo style=\"float:left;margin-left:80px\"><img src=\"tpls/default/images/jz.gif\"/></bdo><span style=\"margin:10px 0px 0 10px; display:block; float:left\">正在加载下10条评论...</span></div>");
				 
				setTimeout(function(){$('#ckgd').before(data);$('#sss').remove();},400);
				//setTimeout("$('#sss').remove()",400);
			    setTimeout("$('#gdpl').show()",400);
			
				
				}
		})
		
		
 }
 
 
 //换一换
function changes(page){
	  var this_li=$("#hyh");          
	  var cache=this_li.data("page"+page);
	      if(undefined!=cache){
		//	alert("have cache");
				$("#hyh ul").empty();
	            $("#hyh ul").append(cache);
				 xuxiao();
				
			}
	else{   
	$.ajax({ 
        type: "POST", 
        url: "xml/change.php", 
        dataType: "text", 
        data: {"chg":true,"page":page}, 
        beforeSend: function(){ 
          // $("p").html("正在登录...");
        }, 
 success: function(data){
	 //alert(data)
	this_li.data("page"+page,data);//缓存记录
	$("#hyh ul").empty();
	$("#hyh ul").append(data);
	 xuxiao();
	 }
})
	}
}

function pinglb(pingjia){
	$.ajax({ 
        type: "POST", 
        url: "xml/pinglun.php", 
        dataType: "text", 
        data: {"pl":true,"pingjia":pingjia}, 
        beforeSend: function(){ 
          // $("p").html("正在登录...");
        }, 
 success: function(data){
	
	 }
})
	
}

    
//小学视频最新最热背景高亮
function changbg(obj)
{
	var arr=document.getElementById("cbg");
	var links=arr.getElementsByTagName("a");
	for(i=0;i<links.length;i++)
	{
		links[i].className="";
	}
	links[obj].className="bg";
	
}
//初中视频最新最热背景高亮
function changbg1(obj)
{
	var arr=document.getElementById("cbg1");
	var links=arr.getElementsByTagName("a");
	for(i=0;i<links.length;i++)
	{
		links[i].className="";
	}
	links[obj].className="bg";
	
}
//高中视频最新最热背景高亮
function changbg2(obj)
{
	var arr=document.getElementById("cbg2");
	var links=arr.getElementsByTagName("a");
	for(i=0;i<links.length;i++)
	{
		links[i].className="";
	}
	links[obj].className="bg";
	
}
//高中视频最新最热背景高亮
function changbg3(obj)
{
	var arr=document.getElementById("navi");
	var links=arr.getElementsByTagName("a");
	for(i=0;i<links.length;i++)
	{
		links[i].className="";
	}
	links[obj].className="navi";
	
}
//鼠标移上和移开变换背景
function lihover(obj)
   {
	   obj.className="lihover";
   }
	   
function liout(obj)
{
   obj.className="liout";
}
